package net.jlibrary.curbparking.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.BatchSize;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.Compositor;
import net.jlibrary.common.core.annotation.OperationType;
import net.jlibrary.common.core.annotation.RecordOperation;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.annotation.SeePurview;
import net.jlibrary.common.core.entity.BaseObject;
import net.jlibrary.group.domain.ParkingPlace;

/**
 * 停车记录
 * 
 * @author fzys
 *
 */
@Entity(name = "tab_parkrecord")
@SeePurview(value = "parkingPlace.globalPath")
@BatchSize(size = 15)
@Compositor("ingressTime desc")
@CodeGenComment(value = "停车记录", genSelect = false)
@RecordOperation(type = { OperationType.SAVE, OperationType.UPDATE })
// implements IPageSearch 
public class ParkRecord extends BaseObject {
	private static final long serialVersionUID = -3453250229544981371L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@SearchField(value = "id", condition = SearchCondition.EQUAL)
	private Long id;

	@Column(length = 50, unique = true)
	@CodeGenComment(value = "流水号", viewText = true, viewList = true, required = true)
	private String serialNumber;// 流水号

	@Column(length = 50, unique = true)
	@CodeGenComment(value = "第三方记录编号", viewText = true, viewList = true, required = true)
	private String recordId;// 第三方记录编号

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "plateNumber_id")
	@CodeGenComment(value = "车牌", viewList = true, required = true)
	private PlateNumber plateNumber;// 车牌

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parkingPlace_id")
	@CodeGenComment(value = "停车区", viewList = true, required = true)
	private ParkingPlace parkingPlace;// 所在停车区

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "berth_id")
	@CodeGenComment(value = "停车区", viewList = true, required = true)
	private Berth berth;// 所在停车区泊位

	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "驶入时间", viewList = true)
	private Date ingressTime; // 驶入时间

	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "驶出时间", viewList = true)
	private Date leaveTime; // 驶出时间

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "status_id")
	@CodeGenComment(value = "停车状态", viewList = true, required = true)
	@RecordOperation
	private ParkRecordStatus status;// 停车状态

	@CodeGenComment(value = "应收费用", viewList = true, required = true)
	private double receivable;// 应收费用

	@CodeGenComment(value = "减免费用", viewList = true, required = true)
	private double deratePrice;// 减免费用

	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "减免时间", viewList = true)
	private Date derateTime;// 减免时间

	@CodeGenComment(value = "实收费用", viewList = true, required = true)
	private double money;// 实收费用

	@CodeGenComment(value = "已推送", viewList = true, required = true)
	private boolean push;// 是否已推送

	@Column(updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "创建时间", viewList = true)
	private Date createdate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastdate;

	@Transient
	private String searchClick;

	public Long getId() {
		return id;
	}

	@Override
	public Serializable getPrimaryKey() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public String getRecordId() {
		return recordId;
	}

	public void setRecordId(String recordId) {
		this.recordId = recordId;
	}

	public PlateNumber getPlateNumber() {
		return plateNumber;
	}

	public void setPlateNumber(PlateNumber plateNumber) {
		this.plateNumber = plateNumber;
	}

	public ParkingPlace getParkingPlace() {
		return parkingPlace;
	}

	public void setParkingPlace(ParkingPlace parkingPlace) {
		this.parkingPlace = parkingPlace;
	}

	public Berth getBerth() {
		return berth;
	}

	public void setBerth(Berth berth) {
		this.berth = berth;
	}

	public Date getIngressTime() {
		return ingressTime;
	}

	public void setIngressTime(Date ingressTime) {
		this.ingressTime = ingressTime;
	}

	public Date getLeaveTime() {
		return leaveTime;
	}

	public void setLeaveTime(Date leaveTime) {
		this.leaveTime = leaveTime;
	}

	public ParkRecordStatus getStatus() {
		return status;
	}

	public void setStatus(ParkRecordStatus status) {
		this.status = status;
	}

	public double getReceivable() {
		return receivable;
	}

	public void setReceivable(double receivable) {
		this.receivable = receivable;
	}

	public double getDeratePrice() {
		return deratePrice;
	}

	public void setDeratePrice(double deratePrice) {
		this.deratePrice = deratePrice;
	}

	public Date getDerateTime() {
		return derateTime;
	}

	public void setDerateTime(Date derateTime) {
		this.derateTime = derateTime;
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}

	public boolean isPush() {
		return push;
	}

	public void setPush(boolean push) {
		this.push = push;
	}

	public Date getCreatedate() {
		return createdate;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}

	public Date getLastdate() {
		return lastdate;
	}

	public void setLastdate(Date lastdate) {
		this.lastdate = lastdate;
	}

	public String getSearchClick() {
		return searchClick;
	}

	public void setSearchClick(String searchClick) {
		this.searchClick = searchClick;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ParkRecord other = (ParkRecord) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
